<!-- 查看圈子成员页面 -->
<!-- 小旗子 2020/8/22日更新-->
<!-- 8.27
		1.添加onload接收communityId-->
<!-- 9.1
		 1.调圈子成员接口-->
<template>
	<view>
			<view class="">
				<FansAndFollows v-for="(item,index) in SummaryList" :key="index" :datas="item" :communityId="communityId"></FansAndFollows>
			</view>
			<UniLoadMore :status="status" color="#7F7F7F" :contentText="contentText"></UniLoadMore>
	</view>
</template>

<script>
	import FansAndFollows from "../../components/FansAndFollows.vue"
	import UniLoadMore from '../../components/plugins/uni-load-more.vue'
	import {
		_ajax
	} from '../../in-xupt-functions.js'
	export default {
		data() {
			return {
				communityId: 0,
				SummaryList: [],
				// loading前：more; loading中：loading; 没有更多了：noMore
				status: "more",
				contentText: {
					contentdown: "", // loading前的文字显示
					contentrefresh: "正在尝试触碰底线~", // loading中的显示
					contentnomore: "再往下也看不到胖次哒！" // 没有更多的显示
				}
			}
		},


		methods: {
			loadMore: function() {
				this.status = "loading";
				setTimeout(() => {
					this.status = "noMore"
				}, 2000)
			},
			// getheight: function(time) {
			// 	setTimeout(() => {
			// 		// 获取当前swiper-item的高度
			// 		let query = uni.createSelectorQuery();
			// 		let page_active = query.select(".page_active");
			// 		page_active.fields({
			// 			size: true
			// 		}, data => {
			// 			// 当设备高度高于swiper-item高度时，直接显示没有更多数据
			// 			uni.getSystemInfo({
			// 				success: (data2) => {
			// 					if (data2.windowHeight - 80 >= data.height) {
			// 						this.status = "noMore"
			// 					}
			// 				}
			// 			})
			// 			this.swiperItemHeight = data.height + 80;
			// 		}).exec();
			// 	}, time)
			// }
		},
		// 从上个页面拿到communityId
		onLoad: function(options) {
			if (options.communityId) {
				this.communityId = options.communityId
			}
			console.log(this.communityId);
			// 模拟从后台拿数据
			uni.showLoading({
				title: '正在加载',
				mask: true
			})
			_ajax({
					url: '/circle/' + this.communityId + '/members',
					method: 'GET',
				})
				.then(res => {
					this.SummaryList = res.data.data
					// 加载结束隐藏动画
					if (res.data.status == 0) {
						uni.hideLoading()
						console.log(res)
					}

				})
			// setTimeout(() => {
			// 	this.SummaryList = [
			// 		[1, 2, 3, 4, 5, 6, 7, 8, 9]
			// 	]
			// 	// 当数据请求成功后改变高度
			// 	// this.getheight(500)
			// }, 200)
		},



		// 触底加载更多
		onReachBottom: function() {
			this.status = 'more';
			this.loadMore()
		},
		components: {
			FansAndFollows,
			UniLoadMore
		}
	}
</script>

<style>

</style>
